home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 4 / ETO Development Tools 4.iso / Essentials / C++ A'Link Files / 1990 / Sep 90 / CPlus.Dev$ 9⁄28⁄90 / 0211-Re C++ bug,missing f-Sep90 next >
Encoding:
Text File  |  1991-03-06  |  2.3 KB  |  63 lines  |  [TEXT/GEOL]

  1. Item forwarded  by  PERRY.G      to PIRO         CATHERS      PHIL.TH
  2.  
  3. Item    1915439                         23-Sept-90        08:39PDT
  4.  
  5. From:   MIKE.VILOT                      ObjectWare, Michael Vilot,PRT
  6.  
  7. To:     MM.XOBJ                         MacroMind, XObject Support,PRT
  8.  
  9. cc:     CPLUS.APPLE$                    C++ Interest List--Apple Employees
  10.         CPLUS.DEV$                      C++ Interest List--Developers
  11.         TIM.SWIHART                     Swihart, Tim
  12.  
  13. Sub:    Re> C++ bug,missing feature
  14.  
  15. Haim,
  16.  
  17.   It's rather difficult to diagnose the problem you are encountering
  18. without more specific information.  I have been able to use private
  19. derivation successfully, so I can suggest that the implementation is
  20. not at fault.
  21.  
  22.   Perhaps the error is arising from a missing base class constructor.
  23. Typically, a derived class constructor forgets to propagate arguments to
  24. an appropriate base constructor, and that implies the base's default
  25. constructor has to be invoked.  If the base class does not provide any
  26. constructors, then a default memberwise constructor can be synthesized.
  27. However, if other constructors exist, then the default will _not_ be
  28. synthesized.
  29.  
  30.   I typically provide default constructor, copy constructor, and assignment
  31. operators for classes with non-trivial initialization semantics.  When I
  32. derive classes from these, I often need to provide derived constructors
  33. that propagate arguments correctly:
  34.  
  35.   class Base {
  36.   public:
  37.     Base() { /* default initialization */ }
  38.     Base(const Base& b) { /* copy initialization */ }
  39.     Base& operator=(const Base& b) { /* destructor & copy semantics */ }
  40.   ...
  41.   };
  42.  
  43.   class Derived : private Base {
  44.   public:
  45.     Derived() /* Base() invoked here */ { /* derived default init */ }
  46.     Derived(const Derived& d) : Base(d) { /* any additional copying */ }
  47.     Base& operator=(const Derived& d) { /*stuff*/ return Base::operator=(d); }
  48.   ...
  49.   };
  50.  
  51. Note that the implicit conversion rules of a derived reference to base
  52. reference ensure that invoking the base class' copy constructor and assignment
  53. operator are type-correct.
  54.  
  55.   As an aside, ``The Annotated Reference Manual'' describes the language
  56. implemented in cfront 2.1 (and derivatives).  There are several changes
  57. not supported in 2.0-based translators, such as Apple's current offering.
  58.  
  59. Hope this helps,
  60.  
  61.   Mike
  62.  
  63.